package cn.edu.jxau.lang;

import com.sun.javafx.tools.ant.Callbacks;
import net.sf.cglib.proxy.*;
import org.junit.Test;

import java.lang.reflect.Method;

/**
 * Desc:
 * ------------------------------------
 * Author:fulei04@meituan.com
 * Date:2017/12/21
 * Time:上午8:34
 */
public class Foo {

    @Test
    public void test() {

        Database database = getDatabase("Fudashi");
        //database.insert();
        database.delete();
        //database.update();
        database.select();
    }

    private Database getDatabase(String username) {

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(Database.class);
        enhancer.setCallbacks(new Callback[]{NoOp.INSTANCE,new AuthInterceptor(username)});
        enhancer.setCallbackFilter(new AuthInterceptorFilter());
        return (Database) enhancer.create();
    }
}